package edu.fiu.cis.selfhealingdisk;

public interface BlockMapper {
	
	/**
	 * Given the info in the constructor, what is the min number of blocks required for
	 * a complete mapping.
	 * 
	 * @return
	 */
	public long requiredPhysicalBlocks();
	
	/**
	 * Take a logical block number and get
	 *    the physical block number.
	 * 
	 * @param logicalBlock
	 * @return
	 */
	public long calcPhysicalBlock(long logicalBlock);
	
	/**
	 * Take a physical block number and get
	 *    the logical block number. If the physical
	 *    block does not map to a logical block -1
	 *    is returned.
	 * 
	 * @param physicalBlock
	 * @return
	 */
	public long calcLogicalBlock(long physicalBlock);
	
	/**
	 * Take a logical block number and get
	 *    the parity group number.
	 * 
	 * @param logicalBlock
	 * @return
	 */
	public long calcParityGroupFromLogicalBlock(long logicalBlock);
	
	/**
	 * Take a physical block number and get
	 *    the parity group number.
	 * 
	 * @param physicalBlock
	 * @return
	 */
	public long calcParityGroupFromPhysicalBlock(long physicalBlock);

	/**
	 * Take a block number and a unit (data or parity) number
	 * 
	 * @param block
	 * @return
	 */
	public long calcUnitFromPhysicalBlock(long physicalBlock);
	
	/**
	 * Take a block number and a unit (data or parity) number
	 * 
	 * @param logicalBlock
	 * @return
	 */
	public long calcUnitFromLogicalBlock(long logicalBlock);

	/**
	 * Take a physical block and returns the first and last block of the parity unit 
	 * @param physicalBlock
	 * @return
	 */
	public long[] calcParityBlocks(long physicalBlock);
	
	/**
	 * Take a physical block and returns the block position inside the unit
	 * @param physicalBlock
	 * @return
	 */
	public int calcRelPositionInPhysicalUnit(long physicalBlock);
	
	
	
	
	/**
	 * @return the parityIndex
	 */
	public int getParityIndex();
	
	/**
	 * @return the modIndex
	 */
	public long getModIndex();

	/**
	 * @return
	 */
	public long requiredPartitions();
	
	/**
	 * @return the blocksPerDataUnit
	 */
	public long getBlocksPerDataUnit();
	
	/**
	 * @return the blocksPerParityUnit
	 */
	public long getBlocksPerParityUnit();

	/**
	 * @return the blocksPerGroup
	 */
	public long[] getBlocksPerGroup();

	/**
	 * @return the groupsPerPartiton
	 */
	public long getGroupsPerPartiton();
	
	/**
	 * @return
	 */
	public long getUnitsPerPartition();
	
}
